import { Form, FormItemProps, FormProps } from "antd";

export interface MyFormItemProps extends FormItemProps {
  content?: React.ReactNode;
}

export interface MyFormProps extends FormProps {
  conf?: MyFormItemProps[];
  itemBottom?: string;
}
export function MyForm(props: MyFormProps) {
  const { conf = [], itemBottom = "24px" } = props;
  return (
    <Form {...props} clearOnDestroy>
      {conf.map((item) => (
        <Form.Item
          key={item.name}
          name={item.name}
          label={item.label}
          rules={item.rules}
          style={{ marginBottom: itemBottom }}
        >
          {item.content ? item.content : null}
        </Form.Item>
      ))}
    </Form>
  );
}
